
library(testthat)
library(blma)
library(tictoc)
library(parallel)

cores <- detectCores()

test_that('eyeData produces correct results BIC', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results BIC')
    result <- sampler(100000, vy, mX, prior='BIC', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.003070000000000000,0.004640000000000000,0.001520000000000000,
0.001620000000000000,0.002320000000000000,0.003190000000000000,
0.001350000000000000,0.003650000000000000,0.001550000000000000,
0.002110000000000000,0.052030000000000000,0.002930000000000000,
0.002670000000000000,0.001800000000000000,0.001480000000000000,
0.003370000000000000,0.001370000000000000,0.001460000000000000,
0.002550000000000000,0.001300000000000000,0.001390000000000000,
0.001750000000000000,0.001910000000000000,0.001330000000000000,
0.001190000000000000,0.003670000000000000,0.001390000000000000,
0.011089999999999999,0.001110000000000000,0.003510000000000000,
0.004030000000000000,0.001300000000000000,0.002240000000000000,
0.001780000000000000,0.001570000000000000,0.005390000000000000,
0.001510000000000000,0.002090000000000000,0.001580000000000000,
0.001350000000000000,0.001530000000000000,0.035369999999999999,
0.001650000000000000,0.001530000000000000,0.001190000000000000,
0.001770000000000000,0.001490000000000000,0.001460000000000000,
0.002200000000000000,0.005640000000000000,0.001690000000000000,
0.002900000000000000,0.001450000000000000,0.009370000000000000,
0.010200000000000001,0.001230000000000000,0.001600000000000000,
0.001890000000000000,0.002760000000000000,0.008000000000000000,
0.001360000000000000,0.027779999999999999,0.002120000000000000,
0.001990000000000000,0.001860000000000000,0.008210000000000000,
0.001630000000000000,0.001590000000000000,0.001250000000000000,
0.001920000000000000,0.016410000000000001,0.001450000000000000,
0.001560000000000000,0.001710000000000000,0.001530000000000000,
0.022780000000000002,0.001650000000000000,0.002820000000000000,
0.001260000000000000,0.001760000000000000,0.001330000000000000,
0.001350000000000000,0.001620000000000000,0.001670000000000000,
0.003870000000000000,0.001860000000000000,0.177290000000000003,
0.001750000000000000,0.002050000000000000,0.020020000000000000,
0.001420000000000000,0.004860000000000000,0.002670000000000000,
0.001230000000000000,0.001560000000000000,0.004000000000000000,
0.001730000000000000,0.001280000000000000,0.010890000000000000,
0.002010000000000000,0.002140000000000000,0.007790000000000000,
0.001160000000000000,0.002980000000000000,0.001450000000000000,
0.001690000000000000,0.002850000000000000,0.003450000000000000,
0.021030000000000000,0.009200000000000000,0.003770000000000000,
0.013280000000000000,0.003660000000000000,0.001690000000000000,
0.001650000000000000,0.001480000000000000,0.003150000000000000,
0.001300000000000000,0.001560000000000000,0.001550000000000000,
0.001640000000000000,0.001350000000000000,0.007310000000000000,
0.002680000000000000,0.007050000000000000,0.001420000000000000,
0.008590000000000000,0.001570000000000000,0.001670000000000000,
0.001500000000000000,0.001560000000000000,0.007280000000000000,
0.001310000000000000,0.007270000000000000,0.004490000000000000,
0.022100000000000002,0.002480000000000000,0.001380000000000000,
0.001700000000000000,0.009050000000000001,0.010170000000000000,
0.001450000000000000,0.001530000000000000,0.001330000000000000,
0.001650000000000000,0.006460000000000000,0.007220000000000000,
0.002790000000000000,0.001270000000000000,0.001380000000000000,
0.002520000000000000,0.002020000000000000,0.962860000000000049,
0.005430000000000000,0.026089999999999999,0.001590000000000000,
0.006490000000000000,0.006180000000000000,0.011100000000000000,
0.001640000000000000,0.004920000000000000,0.005640000000000000,
0.002970000000000000,0.017309999999999999,0.001920000000000000,
0.001920000000000000,0.001220000000000000,0.002040000000000000,
0.001240000000000000,0.003300000000000000,0.001500000000000000,
0.021860000000000001,0.003580000000000000,0.001980000000000000,
0.003310000000000000,0.002330000000000000,0.006820000000000000,
0.001410000000000000,0.002230000000000000,0.808849999999999958,
0.057380000000000000,0.018759999999999999,0.006180000000000000,
0.004210000000000000,0.791989999999999972,0.001840000000000000,
0.041329999999999999,0.008900000000000000,0.003100000000000000,
0.002810000000000000,0.001650000000000000,0.001420000000000000,
0.001300000000000000,0.001350000000000000,0.001290000000000000,
0.003110000000000000,0.001560000000000000,0.002200000000000000,
0.003520000000000000,0.055120000000000002
)
, tolerance = 1e-8)
})